当前位置:网站首页>JS daily question (11)
JS daily question (11)
2022-07-29 04:54:00 【Chen Yuchen】
js A daily topic
** hypothesis d It's within the scope of “ empty ” object :
var d = {};
What is accomplished using the following code ?
[‘zebra’,‘horse’].forEach(function(k){
d[k] = undefined;
});
a
**
" answer : The code snippet shown above is in the object d Two properties are set on the . Ideally , For javaScript Object is evaluated as undefined . But running this code marks these properties as objects “ Own attributes ”.
This is a useful strategy to ensure that objects have a set of defined properties . Pass the object to Object.keys Will return an array containing these set keys ( Even if their values are undefined ).
"
The following code will be output to the console .
console.log((function f(n){
return ((n>1)? n*f(n-1) : n )
})(10))
**
This code will output 10 The value of the factorial ( namely 10! or 3,628,800).
Here's why :
Name the function f() Call itself recursively , Until it calls f(1), It simply returns 1. therefore , That's what it does :
f(1):returns n ,which is 1
f(2):returns 2f(1) ,which is 2
f(3):returns 3f(2) ,which is 6
f(4):
.
.
.
**
Make a little progress every day !!!!
边栏推荐
- Implementation of flutter gesture monitoring and Sketchpad
- 如何让照片中的人物笑起来?HMS Core视频编辑服务一键微笑功能,让人物笑容更自然
- Take you to understand JS array
- Flutter 手势监听和画板实现
- MySQL time calculation function
- Tower of Hanoi classic recursion problem (C language implementation)
- 荣耀2023内推,内推码ambubk
- SSM integration, addition, deletion, modification and query
- 带你搞懂 Kubernetes 集群中几种常见的流量暴露方案
- Classes and objects (II)
猜你喜欢

安装spinning up教程里与mujoco对应的gym,报错mjpro150

Deep analysis of data storage in memory (Advanced C language)

Common current limiting methods

电脑无法打开excel表格怎么办?excel打不开的解决方法

Traffic flow prediction pit climbing record (I): traffic flow data set, original data

A little knowledge about management

Excel怎么筛选出自己想要的内容?excel表格筛选内容教程

ios面试准备 - 网络篇

SGuard64.exe ACE-Guard Client EXE:造成磁盘经常读写,游戏卡顿,及解决方案

Corresponding order of 18 and 25coco data of openpose and joint points
随机推荐
iOS面试准备 - 其他篇
Download addresses of various versions of MySQL and multi version coexistence installation
手机工作室网络如何组建?
五个关联分析,领略数据分析师一大重要必会处理技能
WPS如何进行快速截屏?WPS快速截屏的方法
Solution to the fourth game of 2022 Hangzhou Electric Multi school league
RecyclerView通过DPAD按键上下切换焦点 切换到界面外的控件时焦点会左右乱跳
MySQL定时调用预置函数完成数据更新
带你搞懂 Kubernetes 集群中几种常见的流量暴露方案
Delete blank pages in word documents
Use openmap and ArcGIS to draw maps and transportation networks of any region, and convert OMS data into SHP format
Un7.28: common commands of redis client.
SparkSql批量插入或更新,保存数据到Mysql中
Five correlation analysis, one of the most important skills of data analysts
Double type nullpointexception in Flink flow calculation
Command line interactive tools (latest version) inquirer practical tutorial
OpenCV环境搭建
ios面试准备 - 网络篇
EF core: one to one, many to many configuration
Detailed comparison of break and continue functions