How can I tell if an address is an ERC721 or ERC1155 contract?

please help what should i do.

please check this code.

Thanks for your reply, how should it be implemented in Javascript?

don't you know solidity?
you need to implement it in solidity

const isERC721 = async (addr) => {
  const abi = [
    'function supportsInterface(bytes4 interfaceId) view returns (bool)',
  ];
  const contract = new ethers.Contract(addr, abi, provider);
  return await contract.supportsInterface('0x80ac58cd').catch(() => {
    return undefined;
  })
}

Using the above code, he solved my problem.

Great, nice to hear that