JS data type and relational operation syntax

Source: Internet
Author: User

var box=;
Alert (typeof box); box is the undefined type, the value is undefined, and the string returned by the type is undefined

var box=true;
Alert (typeof box); Box is a Boolean, the value is true, and the string returned by the type is a Boolean


var box= "Nephew a good nephew Squeak Squeak";
Alert (typeof box); box is a string type, the value is "nephew a good nephew Squeak Squeak", the type returned by string

var box=253;
Alert (typeof box); box is the number type, the value is 253, the type returns the string



An empty object, which indicates that the pair was created, and there is nothing inside.
Null object, which means no creation, is a null
var box={};
Alert (typeof box); box is the object type, the value is [Object Object], and the string returned by the type is Object


First Kind
var box=null;
Alert (typeof box); box is a null type, the value is null, and the string returned by the type is Object

The second Kind
var box=new Object ();
alert (box); box is a null type, the value is null, and the string returned by the type is Object


Function box () {};
Alert (typeof box); Box is a function, the value is function, and the string returned by the type is function


Alert (typeof new Object ()); You can use the arguments directly


var box;
Alert (typeof box);
Alert (typeof age); You must declare a variable in the future to be initialized to avoid this problem


var box={};
if (box! =null) {//Not equal to NULL, description not NULL object
Alert ("Object has been created successfully");
}


var box=null; This means that you have not created the object, declared the object reference, and initialized to null by default


var box= ""; String initialization with an empty string representation


var box=0; Numeric initialization, typically with 0


var Box=false; Boolean initialization, generally with false and true


alert (undefined==null); are empty, so equal for granted


alert (undefined===null); Can be based on type equality
*/



/*
alert (Number.min_value); Minimum value
alert (Number.MAX_VALUE); Maximum Value


var box=-100e1000; Floating point decimal exceeds the minimum value, so long negative infinity (-infinity)
var box=100e1000; Floating point decimal exceeds maximum, so long as positive infinity (Infinity)

alert (number.positive_infinity); Floating point decimal exceeds maximum, so long as positive infinity (Infinity)
alert (number.negative_infinity); Floating point decimal exceeds the minimum value, so long negative infinity (-infinity)

var box=100e1000;
Alert (isfinite (box)); Whether the range is exceeded, no more than display "true", exceeding the display "false"



var box=0/0; The divisor (the first number) can be zero, the divisor (the second number) cannot be zero; When the first number is zero and the second number is not zero, the value returned is Nan
alert (box); When the first number is zero, the second number does not last, the value returned is Nan; when the first number is nonzero and the second number is zero, the value returned is infinity



alert (Number.NaN); The value of Nan can be obtained by Number.NaN

var box=nan+1;
alert (box); Any result of an operation with Nan is Nan


alert (Nan==nan); Nan is not equal to itself (Nan is not equal to any value)




parseint (); can only reload string to numeric value
Alert (parseint ("456lee")); Returns the integer part, or Nan if the first is not a numeric value
Alert (parseint ("456lee123")); Starts with the first value and ends with the last digit of the first value
Alert (parseint ("12.13")); Automatic removal of decimal parts
Alert (parseint ("")); Return Nan


String type
var box=11;
Alert (typeof box.tostring ()); numeric conversion String Type


Object type
var bao=new Object (2); Object type, value is 2
var age=100; can be added to normal variables
alert (box+age); Type is object, the value returned is 102


var box=new number (60); This approach also creates a number (numeric) object
alert (box); The return value is the 60,object type


var box=new String (Lee "); This approach also creates a string (string) object
alert (box); The return value is the Lee,object type


var box=new Boolean (True); This approach also creates a Boolean (Boolean) object
alert (box); The return value is the True,object type

  

JS data type and relational operation syntax

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.