JS Interview Basics

Source: Internet
Author: User

Problem:

What types of typeof can I get in 1.JS?

Test Center: JS Variable Type

2. When to use double equals = =? When to use the third-level = = =?

Test Center: Forced type conversion

The difference between 3.window.onload and domcontentloaded.

4. Use JS to create 10 <a> tags, click the time to bounce out the corresponding serial number.

Test Centers: Scopes

5. A brief description of how to implement a module loader to achieve basic functionality similar to Require.js.

Test Center: JS Modular

6. Implementing random ordering of arrays

Test Center: JS's basic algorithm.

1. Variables are divided into value types and reference types.

var a = 100;

var B = A;

A = 200;

Console.log (b); The print out is 100;

var a = {age:20};

var B = A;

B.age = 21;

Console.log (A.age); It's 21 printed.

Object array functions are reference types

typeof undefined//undefined;

typeof "AB"//string

typeof 123//number

typeof Ture//boolean

typeof can be distinguished for value types

typeof {}//object

typeof []//object

typeof null//object A null pointer does not point to any object

typeof Console.log//function

typeof distinguishes a value type but cannot differentiate between reference types, except for functions that are not distinguished, but that are objects of type object type, and that reference types can have unrestricted extended properties

2. Forcing type conversions

string concatenation = = (double equals) operator If statement logical operation is a type that can be coerced.

var a = 100 + 10;

Console.log (a); Type of

var b = 100 + "10";

Console.log (b); "10010" string type, because the + number, did a lightweight type conversion, the number into a string, and then connected together.

"//true";

0 = = ""//true; Empty string

Null = = undefined//true; Both null and undefined two can themselves be converted to false, so they can be equal.

JS Interview Basics

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.