Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does javascript distinguish dash sign?

when I use test.tested-by, the javascript reports -by is undefined. I am sure test contains tested-by property. Any solution here?

like image 876
user705414 Avatar asked Nov 19 '25 08:11

user705414


2 Answers

Try using test['tested-by'] instead. tested-by looks like tested minus by

like image 160
Rob Avatar answered Nov 21 '25 21:11

Rob


You need to use:

test["tested-by"]

This way you can provide any property name, even reserved keywords (like "class").

like image 32
MBO Avatar answered Nov 21 '25 21:11

MBO



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!