JS Built-ins
Filebeginner

File β€” name property

πŸ“– Usage Example
const f = new File(['hello'], 'greeting.txt', { type: 'text/plain' })
f.name  // β†’ 'greeting.txt'

File() creates a File object with content, a name, and an optional MIME type.

File Constructor

new File(fileParts, fileName, options) creates a File object. The second argument sets the name property.

Challenge: Verify that new File(['hello'], 'test.txt').name === 'test.txt'.

πŸ’‘ Hints (1)
  • β€’ The second argument to the File constructor is the filename.