Checks if the given file size is less than 2 MB.
This function is commonly used to validate file uploads by ensuring the file size does not exceed the 2 MB limit.
const fileSize = 1.5 * 1024 * 1024; // 1.5 MB in bytesconsole.log(isLt2M(fileSize)); // trueconst largeFileSize = 3 * 1024 * 1024; // 3 MB in bytesconsole.log(isLt2M(largeFileSize)); // false Copy
const fileSize = 1.5 * 1024 * 1024; // 1.5 MB in bytesconsole.log(isLt2M(fileSize)); // trueconst largeFileSize = 3 * 1024 * 1024; // 3 MB in bytesconsole.log(isLt2M(largeFileSize)); // false
The size of the file in bytes.
true if the file size is less than 2 MB, otherwise false.
true
false
Checks if the given file size is less than 2 MB.
This function is commonly used to validate file uploads by ensuring the file size does not exceed the 2 MB limit.
Example