Primary front-End JS Basics

Source: Internet
Author: User
Tags add numbers

Here is a summary of some of the more easily forgotten but in the future work required knowledge points.

1-Three Mesh
var a=3;
/*if (a%2==0)
{
Alert (' Even-numbered ');
}
Else
{
Alert (' singular ');
}*/
A%2==0?alert (' Even-numbered '): alert (' singular ');
2-When we write, we often write to if (a) represents: When A is true, then when does it mean true?
True: true, not 0 digits, non-empty string, non-empty object
False: False, number 0, empty string, empty object, undefined
3-plus there's a place to note
Plus: 1. String Connection 2. Add numbers
Minus: 1. Subtraction of numbers
4-return
Use return to return the value we need.
The parameter arguments about the function
Function Show (A, B)
{
Alert (arguments[0]);//equivalent to a
}
The magical use of arguments: By this method, if I have many parameters, I can directly introduce arguments to manipulate the data.
6-Intermediate insert \ Delete substitution for arrays
var arr=[1,2,3,4,5,6,7,8];

1. Intermediate Delete
/*arr.splice (2, 3);
Alert (arr); */

2. Intermediate insertion
/*arr.splice (5, 0, ' A ', ' B ', ' C ');
Alert (arr); */

3. Replace
Arr.splice (1, 2, ' A ', ' B ');
Alert (arr);
7-break and Continue
#目标: For The Loop
var i=0;

for (i=0;i<5;i++)
{
if (i==2)
{
break;//terminating the entire cycle
continue;//terminates this cycle and continues the next cycle
}
alert (i);
}
7-for in
#目标: for arrays or objects
var obj={a:5, B:3, c:98};
var attr= ';

for (attr in obj)
{
Alert (attr+ ' = ' +obj[attr]);
}
8-json
#{} introduced, the form of a key-value pair
9-about undefined
/*
Undefined1. You really don't have a definition. 2. Although defined, but not given a value
*/

Primary front-End JS Basics

Related Article

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.