简体   繁体   English

JavaScript中的“ / 1 /”是什么意思?

[英]What does “/1/” mean in javascript?

I was reading a piece of code on the internet. 我正在互联网上阅读一段代码。 I saw this line in the javascript code. 我在javascript代码中看到了这一行。 What is "/1/" and "/0/" used for in the following code statements?? 以下代码语句中的“ / 1 /”和“ / 0 /”是什么?

    var firstDate = new Date(String(monthNum) + "/1/" + String(yearNum));
    var lastDate = new Date(String(monthNum + 1) + "/0/" + String(yearNum));

"/1/" and "/0/" are nothing except string literals. "/1/""/0/"除了字符串文字外什么都不是。

You are concatenating these two strings with your month and year string (formed by calling String() , although I think they are not needed) to construct a particular date string. 您正在将这两个字符串与您的monthyear字符串(通过调用String() ,尽管我认为不需要)连接起来以构建特定的日期字符串。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM