I think you are missing one of the methods that was added not too long ago. Array.prototype.at(). To get the last element in an array you can do myArr.at(-1). developer.mozilla.org/en-US/docs/W...
I'm a frontend developer, with a passion for clean and efficient code. I'm using mostly JavaScript, TypeScript, React & CSS. I'm always trying to grow as a developer by learning new technologies.
Interested in software engineering, AI tools, developer productivity, technical debt, and how teams change when coding gets cheaper.
I write longer thoughts here:
https://theendofcoding.com
Laugh all you want, but console.log can be abused by some threat actors very easily. I mean, output of console.log is not escaped ( or otherwise secured ) in any way
I'm not laughing, but your comment was entirely irrelevant. The console.log I used was simply used to display the result of some sample code - in a similar way to the way the original poster used it. No-one is suggesting in any way that it should be used in production code.
How are web-enabled systems attacked? Of course there are many ways, but first and the most used one method of probing is through reverse engineering output of console.log.
what you wrote at the end of the post, is not true.
It will not help to copy the array, because it only creates a reference to that array itself
Instead it is possible as follows
I think you are missing one of the methods that was added not too long ago.
Array.prototype.at(). To get the last element in an array you can domyArr.at(-1).developer.mozilla.org/en-US/docs/W...
Oh Yes !!! Thank You. This pretty usefull and easy
While itβs a cool new method, keep in mind that currently itβs not supported in Safari based devices.
You can easily polyfill it:
This won't work with negative values.
In Safari Technology Preview you can activate it via
Develop > Experimental FeaturesA somewhat unusual way:
Using
console.loginprodis discouragedNaked flames in firework factories are discouraged too
Laugh all you want, but
console.logcan be abused by some threat actors very easily. I mean, output ofconsole.logis not escaped ( or otherwise secured ) in any wayI'm not laughing, but your comment was entirely irrelevant. The
console.logI used was simply used to display the result of some sample code - in a similar way to the way the original poster used it. No-one is suggesting in any way that it should be used in production code.OK. So imagine this:
How are web-enabled systems attacked? Of course there are many ways, but first and the most used one method of probing is through reverse engineering output of
console.log.what you wrote at the end of the post, is not true.
It will not help to copy the array, because it only creates a reference to that array itself
Instead it is possible as follows