当前位置: 首页 > news >正文

赣州市南康区建设局网站温州网站改版

赣州市南康区建设局网站,温州网站改版,网站开发有哪些书籍,天津关键词排名提升javascript 符号by Kevin Kononenko凯文科诺年科(Kevin Kononenko) 理解JavaScript中“ ”符号的直观指南 (A Visual Guide to Understanding the “” Sign in JavaScript) 实际上#xff0c;对于第一次学习编码的人来说#xff0c;赋值运算符(或“ ”符号)实际上会产生误导…javascript 符号by Kevin Kononenko 凯文·科诺年科(Kevin Kononenko) 理解JavaScript中“ ”符号的直观指南 (A Visual Guide to Understanding the “” Sign in JavaScript) 实际上对于第一次学习编码的人来说赋值运算符(或“ ”符号)实际上会产生误导。 (The assignment operator, or “” sign, is actually very misleading for anyone that is learning to code for the first time.) You are taught about the concept of the equals sign for your entire life in math class. 在数学课上您会学到一生的等号概念。 2 x 3 6 2 x 3 6 x²-4 0 x²-4 0 The things on the left side of the equation are equal in value to the things on the right side of the equation. They could be flipped at any time, and the statement would still be true. 等式左侧的值与等式右侧的值相等。 它们可以随时翻转但声明仍然正确。 And then JavaScript comes in like the Kool-Aid man and completely destroys this understanding. 然后JavaScript像Kool-Aid一样出现并彻底破坏了这种理解。 Oh, and don’t get me started with the concept of variables. In algebra class, we are taught that variables can only be equal to numbers that satisfy the equation. For example, 哦别让我开始使用变量的概念。 在代数课上我们被教导变量只能等于满足方程式的数字。 例如 x²-4x3 0 x²-4x 3 0 In the equation above, x can only be 1 or 3. But in JavaScript, the concept of a variable is actually quite different than what you learnt in algebra class. 在上面的等式中 x只能是1或3。但是在JavaScript中变量的概念实际上与您在代数类中学到的完全不同。 This is a huge issue! It means that every time a newbie looks at an “” sign when they are learning about variables, they need to repeat in their head over and over: 这是一个巨大的问题 这意味着每当新手学习变量时每次查看“ ”符号时都需要反复反复进行以下操作 It’s not what you think it means. 这不是您认为的意思。 It’s not what you think it means. 这不是您认为的意思。 It’s not what you think it means. 这不是您认为的意思。 I wanted to create a more memorable way to explain variables than re-teaching what an “” sign means. By the end of this tutorial, you will understand why the “” in variable assignment is more like a ramp that loads up a truck. 我想创建一种比重新教“ ”符号更有意义的方式来解释变量。 在本教程结束时您将理解为什么变量分配中的“ ”更像是装载卡车的坡道 。 This should create a clear guide about the purpose of variables and how to use them throughout your script. 这应该为变量的目的以及如何在整个脚本中使用它们创建清晰的指南。 变量的名称和值 (The Name and the Value of a Variable) Variables are containers for carrying values within your script. In some ways, they are the opposite of variables from algebra. 变量是用于在脚本中携带值的容器。 在某些方面它们与代数变量相反。 You can always give them a new value and restart your script. There is no “permanent” equality to satisfy some condition. 您总是可以给他们一个新值然后重新启动脚本。 没有满足某些条件的“永久”平等。 The left side of the statement has a completely different purpose than the right side of the statement. 该语句的左侧与该语句的右侧具有完全不同的目的。 Here is an example: 这是一个例子 let days 7;This is called declaring the variable. It creates a new truck called days that can drive around your script and deliver its value OR pick up a new value. 这称为声明变量。 它创建了一个名为days的新卡车可以围绕您的脚本行驶并提供其价值或获取新的价值 。 The let keyword announces that you are creating a new variable. Or, in the analogy we are about to use, creating a new truck. let 关键字宣布您正在创建一个新变量。 或者以此类推我们将使用它来创建一辆新卡车。 The variable needs a unique name, which is days here. This distinguishes this truck from all the other trucks. 变量需要一个唯一的名称 这里是天 。 这使这辆卡车与所有其他卡车区分开来。 The assignment operator, or “” sign, loads the value 7, into the truck. 分配运算符 (或“ ”符号)将值 7装入卡车。 It is very hard to break the habit of looking at this like it is math class all over again, so I am going to explain a little more about the different parts of the variable truck. 很难重新习惯像数学课这样的习惯所以我将对可变卡车的不同部分进行更多的解释。 This is the left side of the variable statement. It is not an equation! We are creating a truck with a specific name that we can use over and over again. Any time we look at the left side of the statement, we are calling in a truck with a specific name. 这是变量语句的左侧。 这不是方程式 我们正在创建具有特定名称的卡车我们可以反复使用它。 每当我们查看语句的左侧时我们都在呼叫带有特定名称的卡车。 The assignment operator is just like the ramp of a truck. It loads up a new value. You can load up a new value pretty much any time with the let keyword. 分配操作员就像卡车的坡道。 它加载了一个新值。 您几乎可以随时使用let 关键字加载新值。 As a programmer, we are continuously creating new variables, loading up values and watching the changes around the script. 作为程序员我们正在不断创建新变量加载值并观察脚本周围的变化。 将值重新分配给变量 (Reassigning Values to Variables) So far, we can create a truck that can drive around the script and deliver its value. But what about changing the value that the truck is carrying around? 到目前为止我们可以创建一辆可以围绕脚本行驶并实现其价值的卡车。 但是如何改变卡车随身携带的价值呢 The let keyword allows us to create mutable variables whose values can be changed. If we used the const keyword, it would mean that the value is immutable and unchangeable. let 关键字使我们可以创建可变变量其值可以更改。 如果我们使用const关键字则意味着该值是不可变的且不可更改。 In JavaScript, unlike math, you can simply assign a new value to the variable. Our days variable currently stands for the 7 days in a week. But what if we wanted it to stand for the 5 weekdays? Here is the code we could use. 在JavaScript中与数学不同您可以简单地为变量分配一个新值。 我们的天数变量当前代表一周中的7天。 但是如果我们希望它能在5个工作日内站立该怎么办 这是我们可以使用的代码。 In line 2, we create the days variable with a value of 7. 在第2行中我们创建的days变量的值为7。 On line 4, we re-assign the value of the variable. It is now 5. 在第4行我们重新分配变量的值。 现在是5。 On line 6, the days truck arrives with the value of 5. 在第6行天卡车到达的值为5。 In the GIF above, line 4 puts a new value in the truck that is later used in line 6. 在上面的GIF中第4行在卡车中添加了一个新值该值随后在第6行中使用。 Here is what happens in line 6. 这是第6行发生的情况。 The variable days is not “equal” to anything! It merely carries around the value that you assign to it. This is much more control than you have in math class, where you must discover the value of the variable that satisfies the equation. Now, you are in control! 可变的天数不等于任何东西 它仅包含您为其分配的值。 这比您在数学类中拥有的控制要多得多在数学类中您必须发现满足方程式的变量的值。 现在您已掌控一切 为什么需要变量 (Why Do You Need Variables?) Imagine that you are building an App that tells patients when to take their medication. You need to change the number of days per week based on the medication. Here is a quick snippet. 想象一下您正在构建一个告诉患者何时服药的应用程序。 您需要根据药物更改每周的天数。 这是一个简短的摘要。 In line 2, days gets loaded up with a value of 7. 在第2行中天的值是7。 In line 4, the value of 5 gets loaded up instead. 在第4行中取值为5。 In lines 4 and 6, you use the value of the days variable. Could you hard code this by simply putting the number 7 in line 4 and the number 5 in line 6? Of course you could! 在第4和第6行中使用days变量的值 。 您能通过简单地在第4行中输入数字7和在第6行中输入数字5来对此进行硬编码吗 当然可以 But, as your App grows, you will find that variables are helpful for 2 reasons: 但是随着您的应用程序的增长您会发现变量有帮助的原因有两个 Instantly changing all the appropriate values at once. Let’s say you had three medications that need to be taken for 7 days a week, and three medications that need to be taken for 5 days a week. You don’t want to constantly change the value of days back and forth! You would instead want to use two separate variables. That gives you two separate trucks to drive values around your script. 立即一次更改所有适当的值。 假设您有三种药物需要每周7天服用而三种药物则需要每周5天服用。 你不想不断地改变天的值来回 相反您想使用两个单独的变量。 这样就可以给您两个单独的卡车来驱动脚本中的值。 Remembering what a value stands for. If you hard code a value, you may look back and say, why the heck is that 7? But, if you create a variable, you will remember that it stands for 7 days of the week so you can quickly change it if needed. 记住价值的含义。 如果您硬编码一个值您可能会回头说为什么那是7 但是如果创建一个变量您会记住它代表一周的7天因此您可以根据需要快速进行更改。 赋值运算符右侧的变量名 (Variable Names on Right Side of the Assignment Operator) So far, we have had a pretty hard rule. The name of the variable is on the left side of the assignment operator, while the value is on the right side. 到目前为止我们有一个非常严格的规则。 变量的名称在赋值运算符的左侧而值在右侧。 But what if we have a situation like this? 但是如果我们遇到这种情况怎么办 In line 4, the variable name is on both sides of the assignment operator! This is yet another reason why it is NOT an equals sign! In fact, the relationship between the two sides of the statement stays the same. 在第4行中变量名称在赋值运算符的两侧 这是为什么它不是等号的另一个原因 实际上声明两侧的关系保持不变。 In line 4, we load up a new value onto the days variable. Here is what that looks like. 在第4行中我们将新值加载到days变量中。 看起来像这样。 Notice how we start at the assignment operator and calculate the right side of the statement first? That is because we are assigning a new value to days here. We cannot touch the left side of the statement. Here is what happens next. 请注意我们如何从赋值运算符开始并首先计算语句的右侧 那是因为我们在这里为天分配一个新值。 我们无法触及声明的左侧。 接下来会发生什么。 The days truck pulls up twice in this case. The first time is on the right side of the equation to deliver the old value. And the second time is on the left side of the equation to pick up the new value for days. 在这种情况下天卡车两次起升。 第一次是在等式的右侧以传递旧值。 第二次是在等式的左侧以获取几天的新值。 Our new value for the days variable is 9. In our log statement on line 6, the console would log 9. 我们的days变量的新值为 9。在第6行的log语句中控制台将记录9。 呼吁采取行动 (Call To Action) Did you enjoy this? Give it a clap so others can discover it as well. And, if you want to get notified when I release future tutorials that use analogies, sign up here: 你喜欢这个吗 给它鼓掌以便其他人也可以发现它。 而且如果您希望在以后发布使用类比的教程时得到通知请在此处注册 翻译自: https://www.freecodecamp.org/news/a-visual-guide-to-understanding-the-sign-in-javascript-3de8495ab3f/javascript 符号
http://www.huolong8.cn/news/384281/

相关文章:

  • 做企业网站 asp的cms系统哪个好知识库管理系统
  • 阿里云网站建设部署与发布试题答案市场营销图片高清
  • 网站导航还值得做强比网站建设
  • 延安市城乡建设局网站遵义市播州区住房和城乡建设局官方网站
  • 长春网站建设长春电梯公司做网站需要下载哪些软件
  • 污水处理厂网站建设2017优秀网站设计案例
  • 网站建设网页设计wordpress 资源分享
  • 房产网站建设的功能百度云网页版登录入口
  • 网站专题建设建设信用卡网站是什么
  • 网站实现中英文襄阳网站建设知名品牌
  • 网站模板预览做网站有回扣拿吗
  • 视频网站建设审批世界军事新闻最新消息
  • 课程资源网站开发解决方案品牌宣传型网站建设方案
  • 建设部招标网站网站建设论文摘要
  • 网站源码修复网站空间域名能不能自己续费
  • 图片下载网站哪个好网站建设要做什么
  • 网站开发托管协议上海文明城市建设网站
  • 开发楼盘需要多少钱wordpress4.7.3优化
  • 做的单页html怎么放网站凡客装修
  • 做公司网站都需要哪些东西电子商务网站建设特点
  • 平台网站建设预算表dw网页制作知识点
  • 重庆网站建设夹夹虫公司.可信php网站建设
  • 做网站跟做APP哪个容易做网站怎么选择上市公司
  • 网站维护服务内容济南制作网站公司
  • 速成网站建设网站的title
  • 软件和网站开发dw制作一个手机网站模板
  • 免费做外贸的网站关键词优化好
  • 定制网站建设报价单东莞事件最新消息新闻
  • archigo建筑网站建网站培训机构
  • 用wordpress作下载站点做网站策划需要什么技能