Home > front end >  Javascripe problem
Javascripe problem

Time:11-20

The toString: function () {
Return "the teacher [name=" + this name + ", the age=". + this age +] ", "
}

Inside this name="+ this name +" why do you want to add "+" number

CodePudding user response:

That is not called a plus sign, it is complete: "+ +", you string concatenation, stitching is the value of the object, you write directly name=this. The name, the name of the value is the string '. This name ', rather than this. The value of the name itself, as they want to use a pair of double quotes, because you are the most outside with double quotes, you most outside if using single quotes, it should be '+ enclosing name +'

CodePudding user response:

"The teacher [name=" + this name + ", the age=". + this age + "] "can be split into" the teacher [name=". And this name and age="and this age"] ", which quoted as strings, as usual, the output, enclosing the name and enclosing the age is variable, if your page name='Joe', the age=20, so the final output is: the teacher 20] [name=zhang SAN, age=, + is joining together the string with your variables (name, age)

CodePudding user response:

Return "this is the string" + variable + "this is the string 2"

CodePudding user response:

"The teacher [name=" + this name + ", the age=". + this age + "] "

If you don't add "+" string that a word is dead, and the representative is variable, he is the concrete value can be passed
  • Related