Home Web Front-end JS Tutorial Essentials for javascript programming_JS syntax dictionary_basic knowledge

Essentials for javascript programming_JS syntax dictionary_basic knowledge

May 16, 2016 pm 07:03 PM
javascript dictionary programming

107 javascript syntax dictionary compiled by netizens for the convenience of friends who often use js programming

1.document.write(""); Output statement
2. The comment in JS is //
3. The traditional HTML document sequence is: document->html->(head, body)
4. The DOM order in a browser window is: window->(navigator, screen, history, location, document)
5. Get the name and value of the element in the form: document.getElementById( "ID number of the element in the form").name (or value)
6. A lowercase to uppercase JS: document.getElementById("output").value = document.getElementById("input").value.toUpperCase ();
7. Value types in JS: String, Number, Boolean, Null, Object, Function
8. Convert character type to numeric type in JS: parseInt(), parseFloat()
9. Convert numbers in JS to character type: ("" variable)
10. The length of string in JS is: (length)
11. Characters in JS are connected with characters using the symbol.
12. The comparison operators in JS are: == equal to, != not equal to, >, >=, <.<=
13. Use: var to declare variables in JS
14. Judgment statement structure in JS: if(condition){}else{}
15. Loop structure in JS: for([initial expression];[condition];[upadte expression]) {inside loop }
16. The command to terminate the loop is: break
17. Function definition in JS: function functionName([parameter],...){statement[s]}
18. When the file appears When there are multiple forms, you can use document.forms[0], document.forms[1] instead.
19. Window: open the window window.open(), close a window: window.close(), window Itself: self
20. Status bar settings: window.status="character";
21. Pop-up prompt message: window.alert("character");
22. Pop-up confirmation box: window. confirm();
23. Pop up the input prompt box: window.prompt();
24. Specify the location of the currently displayed link: window.location.href="/blog/URL"
25. Take it out The number of all forms in the form: document.forms.length
26. Close the output stream of the document: document.close();
27. String append connector: =
28. Create a Document elements: document.createElement(), document.createTextNode()
29. Method to get elements: document.getElementById()
30. Set the values ​​of all text members in the form to empty:
var form = window.document.forms[0]
for (var i = 0; i if (form.elements.type == "text"){
      form.elements.value = "";
     }
}
31. Determine whether the check button is selected in JS: document.forms[0].checkThis.checked (the checked attribute represents whether Selected to return TRUE or FALSE)
32. Radio button group (the names of the radio buttons must be the same): take the length of the radio button group document.forms[0].groupName.length
33. Radio button Checked is also used to determine whether the group is selected.
34. The value of the drop-down list box: document.forms[0].selectName.options[n].value (n is sometimes used to determine the name of the drop-down list box plus .selectedIndex) Selected value)
35. Definition of string: var myString = new String("This is lightsword");
36. Convert string to uppercase: string.toUpperCase(); Convert string to lowercase: string.toLowerCase();
37. Return the position where string 2 appears in string 1: String1.indexOf("String2")!=-1 means it is not found.
38. Take the string A character at the specified position: StringA.charAt(9);
39. Take out the substring of the specified starting point and end point in the string: stringA.substring(2,6);
40. Mathematical function: Math. PI (returns pi), Math.SQRT2 (returns the square root), Math.max(value1, value2) returns the highest value of the two numbers, Math.pow(value1,10) returns the tenth power of value1, Math. round(value1) rounding function, Math.floor(Math.random()*(n 1)) returns a random number

41. Define date type variables: var today = new Date();
42 .Date function list: dateObj.getTime() gets the time, dateObj.getYear() gets the year, dateObj.getFullYear() gets the four-digit year, dateObj.getMonth() gets the month, dateObj.getDate() gets the day, dateObj. getDay() gets the date, dateObj.getHours() gets the hours, dateObj.getMinutes() gets the minutes, dateObj.getSeconds() gets the seconds, dateObj.setTime(value) sets the time, dateObj.setYear(val) sets the year, dateObj .setMonth(val) sets the month, dateObj.setDate(val) sets the day, dateObj.setDay(val) sets the day of the week, dateObj.setHours sets the hours, dateObj.setMinutes(val) sets the minutes, dateObj.setSeconds(val) sets the seconds [Note: This date and time starts from 0]
43.FRAME representation: [window.]frames[n].ObjFuncVarName,frames["frameName"].ObjFuncVarName,frameName.ObjFuncVarName
44.parent Represents the parent object, top represents the top object
45. The parent window that opens the child window is: opener
46. Represents the current location: this
47. Used when calling JS functions in hyperlinks :(javascript :) to start with the function name
48. This JS will not be executed in old browsers:
49. Quote a file-style JS:
50. Specify to display in browsers that do not support scripts HTML:
51. When there are both hyperlinks and onCLICK events, the old version of the browser will redirect to a.html, otherwise it will redirect to b.html. Example: dfsadf
52. The built-in objects of JS are: Array, Boolean, Date,Error,EvalError,Function,Math,Number,Object,RangeError,ReferenceError,RegExp,String,SyntaxError,TypeError,URIError
53. Line break in JS: n
54. Window full screen size:
55.JS all represents all the elements below it
56. Focus order in JS: document.getElementByid("Form Element").tabIndex = 1
57.The value of innerHTML is the value of the form element: such as

"how are you"

, then the value of innerHTML is: how are you
58.innerTEXT The value is the same as above, except that the tag will not be displayed.
59.contentEditable can set whether the element can be modified, and isContentEditable returns whether the element can be modified.
60.isDisabled judgment Whether it is a prohibited state. disabled sets the prohibited state
61.length gets the length and returns an integer value
62.addBehavior() is an external function file called by JS. Its extension is .htc
63. window.focus() puts the current window in front of all windows.
64.blur() means losing focus. The opposite of FOCUS().
65.select() means the element is selected.
66 .Prevent users from entering text into the text box: onfocus="this.blur()"
67. Get the number of occurrences of this element on the page: document.all.tags("p (or other HTML tags)" ).length
68. There are two types of form output in JS: modal and non-modal.window.showModaldialog(), window.showModeless()
69. Status bar text setting: window.status ='text', the default status bar text setting: window.defaultStatus = 'text.';
70. Add to favorites: external.AddFavorite("http://www.dannyg.com";,"jaskdlf ");
71. Do nothing when encountering a script error in JS: window.onerror = doNothing; The syntax for specifying an error handle is: window.onerror = handleError;
72. Specify the currently open window in JS The parent window: window.opener, supports multiple continuations of opener.opener...
73. The self in JS refers to the current window
74. The status bar display content in JS: window.status= "Content"
75.top in JS refers to the topmost frame in the frame set
76. Close the current window in JS: window.close();
77. Ask whether to confirm in JS Box: if(confirm("Are you sure?")){alert("ok");}else{alert("Not Ok");}
Window redirection in 78.JS: window.navigate( "http://www.sina.com.cn";);
Print in 79.JS: window.print()
Prompt input box in 80.JS: window.prompt("message" ,"defaultReply");
Window scroll bar in 81.JS: window.scroll(x,y)
82.Window scroll to position in JS: window.scrollby
83.Set in JS Time interval: setInterval("expr",msecDelay) or setInterval(funcRef,msecDelay) or setTimeout
84. The modal display in IE4 in JS does not work in NN: showModalDialog("URL"[,arguments][ ,features]);
85. The handle used before exiting in JS: function verifyClose(){event.returnValue="we really like you and hope you will stay longer.";}} window.onbeforeunload=verifyClose;
86. The file handle used when the form is called for the first time: onload()
87. The file handle called when the form is closed: onunload()
88. The properties of window.location: protocol(http:),hostname(www.example.com),port(80),host(www.example.com:80),pathname("/a/a.html"),hash("#giantGizmo", Refers to jumping to the corresponding anchor), href (all information)
89.window.location.reload() refreshes the current page.
90.window.history.back() returns to the previous page, window .history.forward() returns to the next page, window.history.go (return to which page, you can also use the visited URL)
91.document.write() output without line breaks, document.writeln() Line wrap output
92.document.body.noWrap=true; prevent link text from wrapping.
93.Variable name.charAt(number), take the character of the variable.
94 ."abc".charCodeAt (which number), returns the ASCii code value of which character.
95. String concatenation: string.concat(string2), or use = to connect
96. Variable. indexOf("Character", starting position), returns the first occurrence position (calculated from 0)
97.string.lastIndexOf(searchString[,startIndex]) 마지막 발생 위치입니다.
98.string.match(regExpression), 문자가 일치하는지 확인합니다.
99.string.replace(regExpression,replaceString) 현재 문자열이 있습니다.
100.string.split(구분 기호)은 값을 저장할 배열을 반환합니다.
101.string.substr(start[,length])는 숫자부터 지정된 길이까지의 문자열을 가져옵니다. .
102.string.toLowerCase()는 모든 문자열을 작게 만듭니다.
103.string.toUpperCase()는 모든 문자를 대문자로 만듭니다.
104.parseInt(string[,radix(representing base) ])
105.parseFloat(string[,radix])는 부동 소수점 유형으로 강제 변환됩니다.
106.isNaN(변수): 숫자 유형인지 테스트합니다.
107.Definition 상수 키워드: const, 변수 정의 키워드: var

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Remove duplicate values ​​from PHP array using regular expressions Remove duplicate values ​​from PHP array using regular expressions Apr 26, 2024 pm 04:33 PM

How to remove duplicate values ​​from PHP array using regular expressions: Use regular expression /(.*)(.+)/i to match and replace duplicates. Iterate through the array elements and check for matches using preg_match. If it matches, skip the value; otherwise, add it to a new array with no duplicate values.

What is programming for and what is the use of learning it? What is programming for and what is the use of learning it? Apr 28, 2024 pm 01:34 PM

1. Programming can be used to develop various software and applications, including websites, mobile applications, games, and data analysis tools. Its application fields are very wide, covering almost all industries, including scientific research, health care, finance, education, entertainment, etc. 2. Learning programming can help us improve our problem-solving skills and logical thinking skills. During programming, we need to analyze and understand problems, find solutions, and translate them into code. This way of thinking can cultivate our analytical and abstract abilities and improve our ability to solve practical problems.

Build browser-based applications with Golang Build browser-based applications with Golang Apr 08, 2024 am 09:24 AM

Build browser-based applications with Golang Golang combines with JavaScript to build dynamic front-end experiences. Install Golang: Visit https://golang.org/doc/install. Set up a Golang project: Create a file called main.go. Using GorillaWebToolkit: Add GorillaWebToolkit code to handle HTTP requests. Create HTML template: Create index.html in the templates subdirectory, which is the main template.

Collection of C++ programming puzzles: stimulate thinking and improve programming skills Collection of C++ programming puzzles: stimulate thinking and improve programming skills Jun 01, 2024 pm 10:26 PM

C++ programming puzzles cover algorithm and data structure concepts such as Fibonacci sequence, factorial, Hamming distance, maximum and minimum values ​​of arrays, etc. By solving these puzzles, you can consolidate C++ knowledge and improve algorithm understanding and programming skills.

Problem-Solving with Python: Unlock Powerful Solutions as a Beginner Coder Problem-Solving with Python: Unlock Powerful Solutions as a Beginner Coder Oct 11, 2024 pm 08:58 PM

Pythonempowersbeginnersinproblem-solving.Itsuser-friendlysyntax,extensivelibrary,andfeaturessuchasvariables,conditionalstatements,andloopsenableefficientcodedevelopment.Frommanagingdatatocontrollingprogramflowandperformingrepetitivetasks,Pythonprovid

The Key to Coding: Unlocking the Power of Python for Beginners The Key to Coding: Unlocking the Power of Python for Beginners Oct 11, 2024 pm 12:17 PM

Python is an ideal programming introduction language for beginners through its ease of learning and powerful features. Its basics include: Variables: used to store data (numbers, strings, lists, etc.). Data type: Defines the type of data in the variable (integer, floating point, etc.). Operators: used for mathematical operations and comparisons. Control flow: Control the flow of code execution (conditional statements, loops).

Unleash Your Inner Programmer: C for Absolute Beginners Unleash Your Inner Programmer: C for Absolute Beginners Oct 11, 2024 pm 03:50 PM

C is an ideal language for beginners to learn programming, and its advantages include efficiency, versatility, and portability. Learning C language requires: Installing a C compiler (such as MinGW or Cygwin) Understanding variables, data types, conditional statements and loop statements Writing the first program containing the main function and printf() function Practicing through practical cases (such as calculating averages) C language knowledge

Use golang's error wrapping and unwinding mechanism for error handling Use golang's error wrapping and unwinding mechanism for error handling Apr 25, 2024 am 08:15 AM

Error handling in Go includes wrapping errors and unwrapping errors. Wrapping errors allows one error type to be wrapped with another, providing a richer context for the error. Expand errors and traverse the nested error chain to find the lowest-level error for easy debugging. By combining these two technologies, error conditions can be effectively handled, providing richer error context and better debugging capabilities.

See all articles