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

What are the time objects and reference types of JS

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article mainly explains "what is the time object and citation type of JS". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "what is the time object and citation type of JS".

Basic types: String type, Null type, Number type, Undefined type, Boolean type

Complex types: Object typ

Function:

String type: String is a sequence of Unicode characters, commonly known as a string, which can be expressed in double quotation marks or single quotation marks. There is no difference, just match.

Null type: the Null type has only one value: null, which represents a null pointer, that is, something that does not exist

Number type: the number type of JavaScript is different from other languages. There is no difference between integer and floating point numbers. All of them are Number types, which can represent decimal, octal and hexadecimal.

Undefined type: the Undefined type also has only one value, undefined, which means that the variable is only declared and not initialized, that is, there is a pointer, but the pointer does not point to any space.

Boolean type: Boolean has two values: 1.true2.false

Object types: objects (object) are the core concept of JavaScript and the most important data type. All the data in JavaScript can be regarded as objects, which is what we often say that everything is objects.

The output of the following code? Why?

Varobj1= {a:1,b:2}

Varobj2= {a:1,b:2}

Console.log (obj1==obj2); / / false, because obj1 and obj2 are stored in different locations, so false.

Console.log (obj1=obj2); / / obj2 assigns a value to obj1 to output the content of Object {axi1jib 2}.

Console.log (obj1==obj2); / / assign obj2 to obj1, so obj2 is stored in the same location as obj1, so it is true.

Code

Write a function getIntv to get the interval from the current time to the specified date.

Varstr=getIntv ("2016-01-08")

Console.log (str); / / 20 days, 15 hours, 20 minutes and 10 seconds from New Year's Eve

Code:

Varstr=getIntv ("2017-01-27")

FunctiongetIntv (time) {

Varend=newDate (time)

Varnow=newDate ()

Vartimer=end-now

Varday=Math.floor (timer/ (1000606024))

Vartimer1=timer% (1000606024)

Varhour=Math.floor (timer1/ (10006060))

Vartimer2=timer1% (10006060)

Varmin=Math.floor (timer2/ (100060))

Vartimer3=timer2% (100060)

Varsec=Math.floor (timer3/1000)

Return ("distance" + time+ "and" + day+ "days" + hour+ "hours" + min+ "minutes" + sec+ "seconds")

}

Console.log (str); / / 20 days, 15 hours, 20 minutes and 10 seconds from 2017-01-27

Change a numeric date to a Chinese date, such as:

Varstr=getChsDate ('2015-01-08')

Console.log (str); / / January 8, 2015

Code:

Method 1:

Varstr=getChsDate ('2015-01-08')

FunctiongetChsDate (time) {

Time=time.replace (/-/ gjinghui')

Vararr= []

For (iSuppli)

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