Hacker News new | past | comments | ask | show | jobs | submit | vidro3's comments login

what's the use case for call and apply? in 6 years i think i've written .call once

They can be useful if you're working in situations where preserving and using the correct form of _this_ is necessary. Could be a situation with funky legacy code or writing library/utility functions (like an implementation of debounce) where you can't be certain of the context in which your function is going to be used.

These don't come up a ton in modern code bases in part because of the advent of arrow functions, and in part because of the general trend towards FP / declarative programming in JS/TS and away from OOP / "class" use and thus less need for managing "this" throughout an application. Also most of the time if you really need a utility function it's easier to rely on a bulletproof dependency library like Ramda/Lodash/Underscore... concerns about bundle size notwithstanding.

Another use case is if you need to use array methods on array-like things (this comes up sometimes with DOM manipulation). These data structures are iterables but lack the native array methods like map/filter/reduce etc. If for some reason you can't/don't want to create a new array from your data structure to operate on you can do something like Array.prototype.filter.call(myNodeList, filterFunction). Also not terribly common in modern codebases, but useful to be aware of!


apply could be useful before the spread operator existed.

They can also be a bit useful to call one prototype’s function on another object given you get to pick what “this” is.

But in my 12 years I’ve never used them. They’re likely even less important now that we have arrow functions and other features. They probably were useful library building blocks way back in the day.


Longitude dava sobel


Longitude


Askhistorians on Reddit has a lot of posts on it


They've been saying "rescession soon" for 2 years. Wasn't gdp growth like 5% last quarter? Doesn't indicate a recession to me.


Why does an election year indicate a recession?

Rather, who precisely wants a recession now, in your opinion?


>Why does an election year indicate a recession?

Alone, it doesn't

>Rather, who precisely wants a recession now, in your opinion?

I don't think you need more than one guess to figure out the average political leaning of most CEOs and Chairs of corporate boards and then combine that with who is the incumbent


Jerome Powell


any salary range?


I always assumed the podcast was current with the show but it seems like it's about 4 weeks behind.

e.g. I have Tycho Brahe on March 2 in my podcast app, rss shows it released Feb 2.


The BBC is pushing its Sounds app by lagging the podcast. Disappointing but understandable I guess given they want the opportunity to suggest other programmes.


That's recent. Everybody wants a walled garden.


the Paris Review often prints draft versions of significant stories, poems, essays, etc. with editorial notes and marginalia on them. It really helps to see how these things weren't always in their final state.


i thought cases were already cropping up prior to that move


Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: