Flashcards
Javascript basics 2
Flashcards do conjunto (10)
- 1How do you test something against a regex?var str = 'mystring';
/[^a-zA-Z0-9]/.test( str );
// Tests if string is alphanumeric - 2How do you test a string against a regex?var str = 'mystring';
str.match(/[^a-zA-Z0-9]/);
// Tests if string is alphanumeric - 3How do you convert a string to lower case?var str = 'This Is A StrinG';
var lowerCase = str.toLowerCase(); - 4How do you trim whitespace from a string?var trimmedString = ' This is a string with whitespace '.trim();
- 5How do you iterate over an object in Javascript?for (var prop in obj){
} - 6Is the order of the keys in an ordinary object guaranteed?No
- 7How do you test if something is a function?if (typeof obj === 'function')
- 8What is the best way to round a number to two decimal placesMath.round(value*100)/100
- works better than toFixed() - 9var a = { name : 'james' } var b = a; b.name = 'Anna' What is a.name?a.name is Anna. Javascript assignment is by reference: both variables point to the same object.
- 10How do you copy an object in ES6?var b = Object.assign({}, b)
Informações
- Descrição
- A-Level Javascript FlashCards sobre Javascript basics 2, criado por James Drummond em 18-12-2015.
- Criado por
- James Drummond
- Visualizações
- 2
- Tags
- Avaliação