MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/ProgrammerHumor/comments/1bjjkm6/arejsdevsactuallysane/kvtq7wu/
r/ProgrammerHumor • u/jarulsamy • Mar 20 '24
554 comments sorted by
View all comments
Show parent comment
10
wants a string, not an object
Strings are objects in JS. Try this on a console:
"foobar".constructor // ƒ String() { [native code] }
True, it could check the type of object but obviously it doesn't.
0 u/intbeam Mar 21 '24 Strings are objects in JSNo, strings are stringstype of objectIf strings were objects in JS - as in how "objects" work in JS - there would literally be no way to tell a string apart from anything elseJavaScript doesn't have type categories beyond the native ones; you can't define two different types of objectsDon't confuse a universal API with object orientation 4 u/badmonkey0001 Red security clearance Mar 21 '24 No, strings are stringsStrings are object prototypes.Object.getPrototypeOf("foobar") // String {'', anchor: ƒ, at: ƒ, big: ƒ, blink: ƒ, …} "foobar".__proto__ // String {'', anchor: ƒ, at: ƒ, big: ƒ, blink: ƒ, …}Also from the Mozilla docs:StringThe String object is used to represent and manipulate a sequence of characters. 1 u/intbeam Mar 21 '24 Strings are strings, what you are seeing is an API wrapper, not object orientationMozilla and everyone else should stop gaslighting people into making the mistake of believing that JS is an object oriented language 1 u/badmonkey0001 Red security clearance Mar 21 '24 I'm not saying JS is any good for OO or evangelizing anything else about it. JS is a weird monster. It plays loose with nearly all programming concepts.
0
Strings are objects in JS
No, strings are strings
type of object
If strings were objects in JS - as in how "objects" work in JS - there would literally be no way to tell a string apart from anything else
JavaScript doesn't have type categories beyond the native ones; you can't define two different types of objects
Don't confuse a universal API with object orientation
4 u/badmonkey0001 Red security clearance Mar 21 '24 No, strings are stringsStrings are object prototypes.Object.getPrototypeOf("foobar") // String {'', anchor: ƒ, at: ƒ, big: ƒ, blink: ƒ, …} "foobar".__proto__ // String {'', anchor: ƒ, at: ƒ, big: ƒ, blink: ƒ, …}Also from the Mozilla docs:StringThe String object is used to represent and manipulate a sequence of characters. 1 u/intbeam Mar 21 '24 Strings are strings, what you are seeing is an API wrapper, not object orientationMozilla and everyone else should stop gaslighting people into making the mistake of believing that JS is an object oriented language 1 u/badmonkey0001 Red security clearance Mar 21 '24 I'm not saying JS is any good for OO or evangelizing anything else about it. JS is a weird monster. It plays loose with nearly all programming concepts.
4
Strings are object prototypes.
Object.getPrototypeOf("foobar") // String {'', anchor: ƒ, at: ƒ, big: ƒ, blink: ƒ, …} "foobar".__proto__ // String {'', anchor: ƒ, at: ƒ, big: ƒ, blink: ƒ, …}
Also from the Mozilla docs:
String
The String object is used to represent and manipulate a sequence of characters.
1 u/intbeam Mar 21 '24 Strings are strings, what you are seeing is an API wrapper, not object orientationMozilla and everyone else should stop gaslighting people into making the mistake of believing that JS is an object oriented language 1 u/badmonkey0001 Red security clearance Mar 21 '24 I'm not saying JS is any good for OO or evangelizing anything else about it. JS is a weird monster. It plays loose with nearly all programming concepts.
1
Strings are strings, what you are seeing is an API wrapper, not object orientation
Mozilla and everyone else should stop gaslighting people into making the mistake of believing that JS is an object oriented language
1 u/badmonkey0001 Red security clearance Mar 21 '24 I'm not saying JS is any good for OO or evangelizing anything else about it. JS is a weird monster. It plays loose with nearly all programming concepts.
I'm not saying JS is any good for OO or evangelizing anything else about it. JS is a weird monster. It plays loose with nearly all programming concepts.
View all comments
Show parent comment
10
u/badmonkey0001 Red security clearance Mar 21 '24
Strings are objects in JS. Try this on a console:
True, it could check the type of object but obviously it doesn't.