Objects Flashcards
True or False: The global object itself can be accessed using the “this” operator in the global scope.
True
The global scope consists of ?
The global scope consists of the properties of the global object, including inherited properties, if any.
What global properties return a simple value? Meaning they have no properties or methods.
These global properties return a simple value: Infinity NaN undefined null literal
What are global functions?
Global functions are functions which are called globally rather than on an object and directly return their results to the caller. example: isNaN() parseInt()
What does the global function eval() do? And what is an example?
The eval() function evaluates JavaScript code represented as a string. Syntax: eval(string) Example: eval(new String(“2 + 2”)); // returns a String object containing “2 + 2” eval(“2 + 2”); // returns 4
What does the global function isFinite() do? And what is an example?
The global isFinite() function determines whether the passed value is a finite number. If needed, the parameter is first converted to a number. Syntax: isFinite(testValue) Example: isFinite(-Infinity); // false isFinite(0); // true
What does the global function isNaN() do? And what is an example?
The isNaN() function determines whether a value is NaN or not. Note: coercion inside the isNaN function has interesting rules; you may alternatively want to use Number.isNaN(), as defined in ECMAScript 6, or you can use typeof to determine if the value is Not-A-Number. Syntax: isNaN(testValue) Example: isNaN({}); // true isNaN(true); // false
What does the global function parseFloat() do? And what is an example?
The parseFloat() function parses a string argument and returns a floating point number. Syntax: parseFloat(string) Example: parseFloat(“3.14”); // 3.14 parseFloat(“314e-2”);// 3.14
What does the global function parseInt() do? And what is an example?
The parseInt() function parses a string argument and returns an integer of the specified radix (the base in mathematical numeral systems). Syntax: parseInt(string, radix); Example: parseInt(“ F”, 16); // 15 parseInt(“17”, 8); // 15
What does the global function decodeURI() do? And what is an example?
The decodeURI() function decodes a Uniform Resource Identifier (URI) previously created by encodeURI or by a similar routine. Syntax: decodeURI(encodedURI) Example: decodeURI(“https://developer.mozilla.org/ru/docs/JavaScript_%D1%88%D0%B5%D0%BB%D0%BB%D1%8B”); // “https://developer.mozilla.org/ru/docs/JavaScript_шеллы”
What does the global function decodeURIComponent() do? And what is an example?
The decodeURIComponent() function decodes a Uniform Resource Identifier (URI) component previously created by encodeURIComponent or by a similar routine. Syntax: decodeURIComponent(encodedURI) Example: decodeURIComponent(“JavaScript_%D1%88%D0%B5%D0%BB%D0%BB%D1%8B”); // “JavaScript_шеллы”
What does the global function encodeURI() do? And what is an example?
The encodeURI() function encodes a Uniform Resource Identifier (URI) by replacing each instance of certain characters by one, two, three, or four escape sequences representing the UTF-8 encoding of the character (will only be four escape sequences for characters composed of two “surrogate” characters). Syntax: encodeURI(URI) Example: // high-low pair ok console.log(encodeURI(‘\uD800\uDFFF’));
What does the global function encodeURIComponent() do? And what is an example?
The encodeURIComponent() function encodes a Uniform Resource Identifier (URI) component by replacing each instance of certain characters by one, two, three, or four escape sequences representing the UTF-8 encoding of the character (will only be four escape sequences for characters composed of two “surrogate” characters). Syntax: encodeURIComponent(str);