In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article introduces the knowledge of "how to use web front-end logic operations". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Logic and & &
Var axiomo Bronx 3
Alert (a==0&&b==3) / / true
Alert (a==1&&b==3) / / false
His return value is of Boolean type, and when both conditions are true, the entire statement returns true. If one is not valid, the return value is false.
Logical or | |
Var axiomo Bronx 3
Alert (astat1 | | breadcrumb 3) / / true
Alert (astat0 | | breadcrumbs 4) / / true
Alert (axioms 10 | | breadwinners 40) / / false
His return value is of Boolean type, and when one of the criteria is true, the entire statement returns true. If all is not true, the return value is false.
Logic no!
Var axiomo Bronx 3
Alert (astat1) / / true
Alert (breadbasket 3) / / false
His return value is of Boolean type, and when the judgment condition is not valid, the entire statement returns true. If set, the return value is false.
Self-increasing
At a certain point in time, after going through something special, people will change.
Its return value is an itself, because the parsing order of the browser is from top to bottom from left to right. When we read the statement, the variable an is parsed first. It hasn't done any operation yet, so the result of the statement is variable an at this time.
Var axi1
Alert (averse +); / / 1
Alert (averse +); / /?
+ + a,-- an is the same, because of the parsing order problem, when the parser
Alert (+ + a) / / 2
NaN (a special type of number that is different from itself, indicating a number that is not a number)
Alert (NaN==NaN) / / false
Var axiom 0
Var b
Var c=a+b
Alert (c)
/ / isNaN (num) function, which determines whether the value of the num variable is NaN
Alert (isNaN (c)
Number () method toFixed () method
Number casts any type of data, and the result is a number.
Alert (Number (true)); / / 1 true and false of the Boolean type are converted to 1 and 0, respectively
Alert (Number (25)); / / 25, the numeric type is returned directly
Alert (Number (null)); / / 0, empty object returns 0
Alert (Number (undefined)); / / NaN,undefined returns NaN
Var axiom 1.22222
A.toFixed (2) / / return value is 1.22
A//1.22222
If it is an object, call the toString method to get the return value after the number conversion fails
Var box = {
ToString: function () {
Return '123customers; / / you can change it to return' abc' to view the effect.
}
}
Alert (Number (box)) / / 123
Create an object (Object) type
Created in two ways
1.var obj=new Object ()
2.var obj= {
}
ParseInt () and parseFloat ()
It is also forced to convert data, what is the difference between them?
ParseInt () this method detects the first non-numeric character in a number or string from left to right, and returns everything before it, and returns NaN if the first character in the string is not a number.
Example:
1.parseInt ('123abc') an is the first non-numeric character; if all values before an are returned, the return value of the method is 123.
If 2.parseInt ('abc123') an is the first non-numeric character and is at the beginning of the string, it is determined that the string cannot be converted to a number and returns NaN
ParseFloat () this method retrieves the first one after a number or string. Returns all previous results, and returns NaN if the first character is not a number.
Example:
1.parseFloat ('123.123.123abc'). First。 If the character is not a number, then the previous character is returned, and the method returns 123.123
This is the end of the content of "how to use web front-end logic operations". Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.