oldoc63 / learningfs Goto Github PK
View Code? Open in Web Editor NEWWeb development back and front
Web development back and front
const unknown3 = true;
console.log(typeof unknown3); // Output: boolean
Math.random()
returns a value between 0 (inclusive) and 1 (exclusive).switch(randomNumber)
eightBall
to a reply that a Magic Eight Ball would return.switch (condition) {
case 0:
eightBall = 'prediction here';
break;
case 1:
eightBall = 'another prediction here';
break;
// additional cases...
}
else if
that is easier to read and write.let groceryItem = 'papaya';
switch (groceryItem) {
case 'tomato':
console.log('Tomatoes are $0.49');
break;
case 'lime':
console.log('Limes are $1.49');
break;
case 'papaya':
console.log('Papayas are $1.29');
break;
default:
console.log('Invalid item');
break;
}
// Prints 'Papayas are $1.29'
userInput = userInput.toLowerCase();
undefined
.let price;
console.log(price); // Output: undefined
price = 350;
console.log(price); // Output: 350
console.log(var);
{}
, to designate an object literal:let spaceship = {}; // spaceship is an empty object
.
, or bracket notation,[]
, and the assignment operator,=
to add new key-value pairs to an object or change an existing property.const spaceship = {type: 'shuttle'};
spaceship = {type: 'alien'}; // TypeError: Assignment to constant variable.
spaceship.type = 'alien'; // Changes the value of the type property
spaceship.speed = 'Mach 5'; // Creates a new key of 'speed' with a value of 'Mach 5'
Math.random()
returns a value between 0 (inclusive) and 1 (exclusive).
In order to make this set of numbers range from 0 (inclusive) to 1000 (exclusive) we can multiply the returned value by 1000.
Finally, to ensure we only have whole numbers from 0 to 999 we can round down using Math.floor()
.
invade: function () { ...
const alienShip = {
invade () {
console.log('Hello! We have come to dominate your planet. Instead of Earth, it shall be called New Xaculon.')
}
};
alienShip.invade();
const logSkyColor = () => {
let color = 'blue';
console.log(color); // blue
}
getActualSleepHours()
function, call the getSleepHours()
function for each day of the week. Add the results together and return the sum using an implicit return.let a = 10;
a++;
console.log(a); // Output: 11
const
variable cannot be reassigned. If you try to reassign a const
variable, you’ll get a TypeError
.SyntaxError
.const myPet = 'armadillo';
console.log(`I own a pet ${myPet}.`);
// Output: I own a pet armadillo.
?
?
and are separated by a colon :
true
, the first expression executes.false
, the second expression executes.hello.length;
let spaceship = {
homePlanet: 'Earth',
color: 'silver'
};
spaceship.homePlanet; // Returns 'Earth',
spaceship.color; // Returns 'silver',
this
becomes a bit more complicated when we start using arrow functions for methods.const goat = {
dietType: 'herbivore',
makeSound() {
console.log('baaa');
},
diet: () => {
console.log(this.dietType);
}
};
goat.diet(); // Prints undefined
this
in this case is the global object, without a property dietType, no the calling object.A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.