Fichas
Javascript adv
Fichas del conjunto (11)
- 1How do you check if an object has a property?objName.hasOwnProperty("prop");
Useful for putting variables in the prop check too.
returns true or false - 2how do you generate a random number?Math.random();
generates decimal 0.0 - 0.99 - 3How do you generate a random number between 0 and 20?Math.floor(Math.random() * 21);
(floor round down number) - 4What is the formula for random generating a # between a min and max range? Ex: 0-100(Math.random() * (myMax - myMin + 1) + myMin)
- 5When does should you write functions that start with a capital letter?When they are constructor functions.
When there function is to create new objects. - 6How do you write properties/values in a constructor function object?this.property = value;
use this.
equal sign.
And semicolon - 7How do you call a constructor function?With the new keyword in front.
myCar = new Car(); - 8How do you assign new properties / values to an object?objName.newProp = value;
- 9What does the map method do?It iterates through an array. You can change the values and it stores them into a new array.
Doesn't modify arrays though. - 10What does the concat method do?merges the contents of two arrays into one
- 11join method. arrayName.join(" ");joins things of an array into a string.
takes an delimeter(usually a space) to put between each array value.
Información
- Descripción
- Fichas sobre Javascript adv, creado por Alexander Lynds el 10/06/2017.
- Creado por
- Alexander Lynds
- Visitas
- 0
- Valoración