When writing code we sometimes encounter situations where we need to parse the arithmetic expression ourselves, this article simply describes using JavaScript to implement the parsing of simple arithmetic expressions.
First, familiar with the
Summary
For the time being, I thought of 3 methods. If readers think of other useful methods, they can also communicate
parseintBitwise operatorsMath.floor Math.ceil
Description
First, parseint
1. Examples
parseint
Working with each item in the collection is a very common operation, and JavaScript provides a number of ways to iterate over a collection, from simple for and for Each loop to map (), filter (), and array comprehensions (arrays of derivations). In
JavaScript has a bad reputation on the internet, but it's hard to find another language like it's so dynamic, so widely used, so rooted in our lives. Its low learning threshold makes many people call it a pre-school scripting language, and another
Label
To use JavaScript in HTML, you need to use the tag and define the Type property value as Text/javascript, as shown in the previous Alert pop-up prompt box example:
Copy Code code as follows:
Usually separate
A registration box for form validation processing
As shown in figure
A simple validation hint function
Code thinking is also relatively simple
The input box is detected and processed when it loses focus
form has onsubmit = "return check ()"
1, the use of JS file management code
All the code as far as possible in the JS file, and then use the script in the HTML file introduction, the introduction of the attention placed behind the body tag, and do not use type or language.
2. Writing
This example analyzes the usage of eval functions in JavaScript. Share to everyone for your reference. The specific analysis is as follows:
Eval () has only one parameter, and if the incoming argument is not a string, it returns this argument
The example in this article analyzes the use of sort () in JavaScript. Share to everyone for your reference. The specific analysis is as follows:
Syntax for functions:
Arrayobject.sort (SortBy)
You are not the right way but your love
The example in this article describes the method of JavaScript conversion binary encoding to ASCII code. Share to everyone for your reference. as follows:
enter some binary to decode:
The wants this article to help you with
Having studied a DSL for a while, and discovered so many interesting things, JavaScript uses most of the things that are chained to the call (method chaining). The interesting thing is Martin Flower points out:
Copy Code code as follows:
About the file API here is not explained in detail, small partners to their own Niang it, we will use the file handle to read the file content, this is achieved through the FileReader, through the FileReader interface, we can asynchronously load the
What is callback
Copy Code code as follows:
A callback function is a function called by a function pointer. If you pass the pointer (address) of a function to another function as an argument, when the pointer is used to call the
This example describes the way JavaScript uses pointer manipulation to implement the Josephson problem. Share to everyone for your reference. The specific analysis is as follows:
Before implementation of course to write some of the JS array of the
The following content mainly through the JS code to introduce you, the code is relatively simple, including comments, there are good suggestions welcome.
The following figure, when a query condition contains a date, such as "2012-3-4", verifies
Browser sniffing is now deprecated, but it is needed on some occasions. For example, some statistical scripts. In the standard browser, provided the document.implementation.hasfeature, unfortunately there are bugs, inaccurate, at present, the
Let's take a look at an example
Note that:
AddEventListener and attachevent difference in the first argument the former is click the latter is the onclick
AddEventListener is running in the element scope where the element is
The development of DOM is related to the trend of web standardization. Only based on the correct semantic logic, DOM can play its function correctly. Today, the right semantic structure, performance and content separation requirements, have become
Programming paradigm
The programming paradigm is a framework that consists of thinking about problems and realizing the vision of a problem. Many modern languages are clustering paradigms (or multiple paradigms): They support many different
The recent whim, the project is over, use JavaScript to write a small game, practice and accept it, write a bad also ask heroes to give critical suggestions.
The HTML code is as follows
score: & Lt;div id= "G21" class=
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.