0

This comes from a project I downloaded to learn from:

;['delete', 'get', 'post', 'put', 'patch'].forEach((method) => {
    test(method, async () => {
      expect(global.fetch).not.toBeCalled()
      await api[method]('/foo')
      expect(global.fetch).toHaveBeenCalledWith(
        'https://api.foo.com/foo',
        expect.objectContaining({ method })
      )
    })
  })

I've yet to see a line in js that starts with a semi-colon.

Can anyone explain this?

Tycholiz
  • 1,102
  • 4
  • 17
  • 33
  • It does nothing special (behaves like every other semicolon). In your case (without seeing more code) it does nothing – Wendelin Aug 20 '19 at 17:57
  • Is that all of the code? Usually, ';' are delimiters for the language parser. I wonder if this delimits an unsee statement. Otherwise, it's probably just delimiting nothing and being passed over by the language parser. – Matthew E. Miller Aug 20 '19 at 17:57
  • https://stackoverflow.com/questions/7365172/semicolon-before-self-invoking-function – CFNinja Aug 20 '19 at 17:58
  • if it is in a separate file which is included inside another file where you are including some more script files **before** this file then it might – Muhammad Omer Aslam Aug 20 '19 at 17:58
  • https://stackoverflow.com/questions/7145514/whats-the-purpose-of-starting-semi-colon-at-beginning-of-javascript – Carmine Tambascia Aug 20 '19 at 17:59

0 Answers0