Skip to content
Better HN
Top
New
Best
Ask
Show
Jobs
Search
⌘K
0 points
rbobby
10y ago
0 comments
Share
> basic null check
What's funny to me is that leftpad(null, 6, ' ') outputs " null".
undefined | Better HN
0 comments
default
newest
oldest
ansgri
10y ago
Am I right that len(" null") here is 5, so it's working incorreclly?
daveloyall
10y ago
I think the joke here is that javascript has a long history of thinking that this:
null
is the same as this:
"null"
...Which it isn't.
rbobby
OP
10y ago
Thought it was a typo on my part... but HN seems to be trimming running spaces.
talideon
10y ago
HN isn't: your browser is. Runs of whitespace are collapsed in HTML to single spaces unless specifically styled otherwise. You can verify that they're there by viewing the page source.
1 more reply
j
/
k
navigate · click thread line to collapse