Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Analysis of JavaScript dynamic types, string values and numerical examples

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article introduces the relevant knowledge of "JavaScript dynamic type, string value, numerical example analysis". 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!

JavaScript has dynamic types

JavaScript has dynamic types. This means that the same variable can be used as different types:

Example

Var x; / / now x is undefined

Var x = 7; / / now x is a numeric value

Var x = "Bill"; / / now x is a string value

JavaScript string value

A string (or text string) is a string of characters (such as "Bill Gates").

The string is surrounded by quotation marks. You can use single or double quotation marks:

Example

Var carName = "Porsche 911"; / / use double quotation marks

Var carName = 'Porsche 911'; / / use single quotation marks

You can use quotation marks within a string, as long as they do not match the quotation marks that surround the string:

Example

Var answer = "It's alright"; / / single quotation marks within double quotation marks

Var answer = "He is called 'Bill'"; / / single quotation marks within double quotation marks

Var answer ='He is called "Bill"; / / double quotation marks within single quotation marks

JavaScript value

JavaScript has only one numeric type.

You can write a value with or without a decimal point:

Example

Var x1 = 34.00; / / with decimal point

Var x2 = 34; / / without decimal point

Very large or ultra-small values can be written by scientific counting:

Example

Var y = 123e5; / / 12300000

Var z = 123eMur5; / / 0.00123

This is the end of the content of "JavaScript dynamic type, string value, numerical example analysis". Thank you for 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.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report