Data type 2
3. Boolean Type (Boolean)
Description: Unlike strings, do not enclose Boolean values in quotation marks. A Boolean value of false and the string "false" are two different things.
regulation: Boolean data can only have two values of true and false;
var like=true; var like=false;
4. Objects (object)
Description: JavaScript is an object-oriented language, so you can use object-oriented thinking to make an object a data entity that is composed of a collection of properties and methods that are related to each other.
Note: objects are the focus of JavaScript and will continue to be used for a variety of objects in the coming days.
JavaScript objects: Array Object , A Boolean object, a Date object, aMath object, a number object, a String object, aRegExp object, a global property, and a function
For example, use the Date object to handle the dates and times:
//Create a new date () objectvarToday =NewDate (); Get yearvarYear =today.getfullyear ();//GetMonth () Gets the month that starts at 0varmonth = Today.getmonth () + 1;//GetDay () Gets the week, and it starts at 0.varweek=Today.getday ();//Get Dayvarday=taday.getdate ();//Get HoursvarHour=taday.gethours ();//Get minutesvarMinute=taday.getminutes ();//gets the number of secondsvarSecond=taday.getseconds ();
5.Array Array (object)
Description: Our variables generally can only store one content so it's actually a single container. Our arrays generally have one or more values, so the array is a large container, and the array is also a JavaScript object
component: An array is actually a multi-container array of multiple (key-value) indexes that start at 0 by default
Cases:
var New Array (23,23,45,56,435); var arr2 = [23,34,546]; var New Array (); arr3[0] = 234; arr3[1] = 234;
6.javascript-null, undefined
null: null in JavaScript means "nothing". Null is a special type with only one value. Represents an empty object reference. You can set NULL to empty the object.
Undefined: in JavaScript, Undefined is a variable that has no value set. typeof A variable that has no value returns undefined. You can also set the undefined to empty the object.
The difference between Undefined and Null is that the result of TypeOf Undefined is Undefined, and typeof null results in an object.
Iii. viewing and conversion of data types
1. View data type typeof
Description: Typeo can see the type of the variable.
Syntax:alert (typeof variable name or data);
2. Convert to String
var false ; alert (married.tostring ()); // outputs "false" var = +; alert (age.tostring ()); // outputs "
3. Convert to Digital
Convert parseint () to integers
Parsefloat () converted to floating point number
var test = parseint ("blue"); // returns NaN var test = parseint ("1234blue"); // returns 1234 var test = parseint ("22.5"); // returns var test = parsefloat ("1234blue"); // returns 1234 var test = parsefloat ("22.5"); // returns 22.5
Iv. operators
1. Arithmetic operators (+-*/%)
Description: Add, subtract, multiply, divide, and seek remainder, where% is the remainder operation
The results of the addition of different types of data, for example:
Alert ("ten" +) //return 1020; Alert (ten +) //return;
JavaScript Beginner Chapter _2