---
title: "js 判断是否为null(非空)"
author: "cyf-123456"
date: "2009-09-26T13:27:33Z"
tags: []
slug: "js-null"
draft: false
lastmod: "2009-09-26T13:27:33Z"
id: 477828
url: "https://cyf-123456.iteye.com/blog/477828"
---

在js里总遇到判断传参是否为空的情况，但是js里面通过obj==null判断好像作用不明显，

不过通过“!”判断，事半功倍。做个小计

function replace\_null(str){  
 if(!str){

  //alert('null');  
  document.write('0');  
 }else{  
  document.write(str);  
 }  
}